﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcAppDemo.Models.DinnerFormViewModel>" %>
<%= Html.ValidationSummary("Please correct the errors and try again.") %>
<% using (Html.BeginForm())
   { %>
<fieldset>
    <div id="dinnerDiv">
        <p>
            <label for="Title">
                Dinner Title:</label>
            <%= Html.TextBox("Title", Model.Dinner.Title) %>
            <%=Html.ValidationMessage("Title", "*") %>
        </p>
        <p>
            <label for="EventDate">
                Event Date:</label>
            <%= Html.TextBox("EventDate", Model.Dinner.EventDate) %>
            <%= Html.ValidationMessage("EventDate", "*") %>
        </p>
        <p>
            <label for="Description">
                Description:</label><br />
            <%= Html.TextArea("Description", Model.Dinner.Description) %>
            <%= Html.ValidationMessage("Description", "*") %>
        </p>
        <p>
            <label for="Address">
                Address:</label>
            <%= Html.TextBox("Address", Model.Dinner.Address) %>
            <%= Html.ValidationMessage("Address", "*") %>
        </p>
        <p>
            <label for="Country">
                Country:</label><br />
            <%= Html.DropDownList("Country", Model.Countries) %>
            <%= Html.ValidationMessage("Country", "*") %>
        </p>
        <p>
            <label for="ContactPhone">
                Contact Phone #:</label>
            <%= Html.TextBox("ContactPhone", Model.Dinner.ContactPhone) %>
            <%= Html.ValidationMessage("ContactPhone", "*") %>
        </p>
        <%--       <p>
            <label for="Latitude">
                Latitude:</label><br />
            <%= Html.TextBox("Latitude", Model.Dinner.Latitude)%>
            <%= Html.ValidationMessage("Latitude", "*")%>
        </p>
        <p>
            <label for="Longitude">
                Longitude:</label><br />
            <%= Html.TextBox("Longitude", Model.Dinner.Longitude)%>
            <%= Html.ValidationMessage("Longitude", "*")%>
        </p>--%>
        <p>
            <%= Html.Hidden("Latitude", Model.Dinner.Latitude)%>
            <%= Html.Hidden("Longitude", Model.Dinner.Longitude)%>
        </p>
        <p>
            <input type="submit" value="Save" class="btn-spec" />
            <input type="button" value="Back" onclick="javascript:history.go(-1)" class="btn-spec" />
        </p>
    </div>
    <div id="mapDiv">
        <%Html.RenderPartial("Map", Model.Dinner); %>
    </div>
</fieldset>
<% } %>
<script type="text/javascript">
    $(document).ready(function () {
        $("#Address").blur(function (evt) {
            $("#Latitude").val("");
            $("#Longitude").val("");
            var address = jQuery.trim($("#Address").val());
            if (address.length < 1)
                return;
            FindAddressOnMap(address);
        });
    }); 
</script>
